package de.XPortLib.Interfaces;

import java.util.Calendar;

import de.XPortLib.TimerEvent;
import de.XPortLib.Exceptions.DataTransmissionException;
import de.XPortLib.Exceptions.TCPCommunicationException;

public interface XPortControllerIF {

	/**
	 * default getter method 
	 * @return 
	 * 		the current set IP Address for the XPort
	 */
	public abstract String getIpAddress();

	/**
	 * sets the IP Address for the XPort 
	 */
	public abstract void setIpAddress(String ipAddres);

	/**
	 * default getter method 
	 * @return 
	 * 		the current set port for the XPort
	 */
	public abstract int getPort();

	/**
	 * sets the port for the XPort 
	 */
	public abstract void setPort(int port);

	/**
	 * reads the current relais status
	 * @return
	 * 			boolean array with status for each relais
	 * @throws DataTransmissionException
	 * @throws TCPCommunicationException
	 */
	public abstract boolean[] readRelais() throws DataTransmissionException,
			TCPCommunicationException;

	/**
	 * toggles the relais ith the given number.
	 * 
	 * @param channel
	 * 			relais number to toggle
	 * @return
	 * 			new relais status after switching
	 * @throws DataTransmissionException
	 * @throws TCPCommunicationException
	 */
	public abstract boolean[] toggleRelais(int channel)
			throws DataTransmissionException, TCPCommunicationException;

	/**
	 * reads the timerevent at given position
	 * @param nr
	 * 			the position
	 * @return
	 * 			the TimerEvent object retrieved from XPort
	 * @throws DataTransmissionException
	 * @throws TCPCommunicationException
	 */
	public abstract TimerEvent readTimer(int nr)
			throws DataTransmissionException, TCPCommunicationException;

	/**
	 * reads all timerevents
	 * @return
	 * 			the array of TimerEvents
	 * @throws DataTransmissionException
	 * @throws TCPCommunicationException
	 */
	public abstract TimerEvent[] readTimers() throws DataTransmissionException,
			TCPCommunicationException;

	/**
	 * writes a timerevent to the given position (existing events are overwritten)
	 * @param nr
	 * 			the position
	 * @param timer
	 * 			the timer object to be saved
	 * @return
	 * 			the total number of events after writing this new event
	 * @throws DataTransmissionException
	 * @throws TCPCommunicationException
	 */
	public abstract int writeTimer(int nr, TimerEvent timer)
			throws DataTransmissionException, TCPCommunicationException;

	/**
	 * writes a timerevent to the given position (existing events are overwritten)
	 * @param nr
	 * 			the position
	 * @return
	 * 			the total number of events after writing this new event
	 * @throws DataTransmissionException
	 * @throws TCPCommunicationException
	 */
	public abstract int deleteTimer(int nr) throws DataTransmissionException,
			TCPCommunicationException;

	/**
	 * sets Date and Time
	 * @param cal
	 * 			Calendar object containing the date and time information to be set.
	 * @throws DataTransmissionException
	 * @throws TCPCommunicationException
	 */
	public abstract void setDateTime(Calendar cal)
			throws DataTransmissionException, TCPCommunicationException;

}